#include <iostream>
#include <string>

using namespace std;

void readString(string& str) {
    str = "";
    char c;

    scanf("%c",&c);
    while (c != '\n' && c != EOF) {
        str += c;
        scanf("%c",&c);
    }
}

int getSubStringIndex(const string& str, const string& subStr) {
    int strLen = str.size();
    int subLen = subStr.size();
    int len = strLen + subLen + 1;
    int* z = new int[len];

    z[0] = len;
    int r = 1;

    for (int i = 1; i < len; ++i) {
        z[i] = 0;
        if (i == subLen) continue;

        if (i >= r + z[r] - 1) {
            while (i + z[i] < len && i + z[i] != subLen) {
                if (i + z[i] < subLen && subStr[z[i]] != subStr[i + z[i]]) break;
                if (i + z[i] > subLen && subStr[z[i]] != str[i + z[i] - subLen - 1]) break;
                ++z[i];
            }
            r = i;
        } else {
            if (z[i - r] < r + z[r] - i) z[i] = z[i - r];
            else {
                int tmp = r + z[r] + z[i];
                while (tmp < len && tmp != subLen && tmp - i != subLen) {
                    if (tmp < subLen && subStr[tmp - i] != subStr[tmp]) break;
                    if (tmp - i < subLen && tmp > subLen && subStr[tmp - i] != str[tmp - subLen - 1]) break;
                    ++z[i];
                    ++tmp;
                }
                z[i] += r + z[r] - i;
                r = i;
            }
        }

        if (z[i] == subLen && i > subLen) {
            delete[] z;
            return i - subLen - 1;
        }
    }

    delete[] z;
    return -1;
}


int main() {
    string input, subString;

    readString(input);
    readString(subString);

    while (subString != "") {
        if (input.length() < subString.length()) cout<<"NO"<<endl;
        else {
            int n = -1;
            if ((n = getSubStringIndex(input, subString)) != -1) cout<<n<<endl;
            else cout<<"NO"<<endl;
        }

        readString(subString);
    }

    return 0;
}

